<template>
	<view>
		<u-navbar :title="$t('签到有奖')" background="{ background: '#fff' }" title-color="#000" back-icon-color="#000"
			:is-fixed="false" :immersive="false"></u-navbar>
		<view class="content-view">
			<view class="qianbox">
				<view class="listbox">
					<view class="list" v-for="(item,idx) in list" :key="idx">
						<view class="tit">
							<text>{{$t('第')}} {{item.day}}{{$t('天')}}</text>
							<image src="../../../static/image/qiantit.png" mode=""></image>
						</view>
						<view class="goods">
							<image :src="item.image" mode="widthFix"></image>
						</view>
						<view class="name">
							{{item.give_tip}}
						</view>
						<view class="state" :class="idx < num?'has-state':''">
							{{idx < num? $t('已领取') : $t('未领取')}}
						</view>
					</view>
				</view>

			</view>

			<view class="btn" @click="qian">
				{{ $t("点我签到") }}
			</view>

			<view class="rule" @click="show = true">
				
			</view>
		</view>
		<!-- -->

		<u-popup v-model="show" mode="center" border-radius="16">
			<view class="rulebox">
				<view class="ruletit">{{ $t("签到领福利规则") }}</view>
				<scroll-view class="scroll" scroll-y>
					<rich-text :nodes="data"></rich-text>
				</scroll-view>
				<view class="btn1" @click="show = false">
					{{ $t("确定") }}
				</view>
			</view>

		</u-popup>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				data: '',
				num: '0',
				list: []
			}
		},
		onLoad() {
			uni.loadFontFace({
				family: 'myfont',
				source: 'url("https://img.50api.cn/dingdang/YouSheBiaoTiHei.ttf")',
			})
			if (uni.getStorageSync("user")) {
				this.getDat()
				this.getQian()
			}
		},
		methods: {
			getQian() {
				this.$http({
					url: "api/member/get_qiandao_set_list",
				}).then(res => {
					console.log(res);
					if (res.data.code == 1) {
						if (res.data.data.sign_day != null) {
							this.num = res.data.data.sign_day
						}
						let data = res.data.data.qiandao_set
						this.list = data
					}
				}).catch(err => {});
			},
			qian() {
				// if(this.num == 1)
				this.$http({
					url: "api/member/qiandao",
				}).then(res => {
					console.log(res);
					if (res.data.code == 1) {
						this.$tip.tip(res.data.msg)
						this.getQian()
					} else {
						this.$tip.tip(res.data.msg)
					}
				}).catch(err => {});
			},
			getDat(type) {
				this.$http({
					url: "api/common/get_agreement",
					data: {
						name: 'qiandao_rule'
					}
				}).then(res => {
					if (res.data.code == 1) {
						this.data = res.data.data.content

					} else {
						this.$tip.tip(res.data.msg)
					}
				}).catch(err => {});
			}
		}
	}
</script>

<style>
	@import url("../../../static/pagesA/qiandao.css");
</style>